Related Plugins and Tags

QGIS Planet

QGIS Distance Calculator

I want to find a location that is close to existing industrial areas (red polygons) and away from Sites of Special Scientific Interest (green polygons)

I will do this by using the Proximity (Raster Distance) analysis tool to create distance thematics, then using the Raster calculator to average the distance from each criterion.

Original layers

Original layers

Convert to Raster

The process only works with input files that are in raster format. As our source is in vector format (it’s a polygon .shp file), we need to convert it to a raster file.

It is good practice to add an attribute column, set its value to 1 so the resulting raster has a value of 1 for all the polygons. This can be done using the Field Calculator in the Attribute table.

QGIS Rasterize tool

QGIS Rasterize tool

Change display properties

The raster initially appears as a grey box. Don’t worry, this is normal. I am going to adjust its display properties so I can see the information.

  1. Right click on the layer
  2. Select Properties
  3. Select Stretch to MinMax under Contrast Enhancement
  4. Select the style tab
  5. Tick Invert Colour map. This makes the areas with a value of 1 black and the areas with a value of 0 white
QGIS Layers dialog

QGIS Layers dialog

The colours look quite stark, so I’m going to apply a transparency:-

  1. Select the Transparency tab
  2. In the Transparent Pixel List box, enter 1 under Gray and 50 under % Transparent
QGIS Layers dialog

QGIS Layers dialog

Its appearance is now less over-powering and I can see other layers too:-

QGIS Distance Calculator4

Calculate Proximity/Distance

Now to create a thematic based on the proximity (or distance) between each pixel and the nearest point of a SSSI site:-

  1. Open the Proximity calculator by selecting Raster menu, Analysis, Proximity (Raster Distance)
  2. Select the input raster and output raster (I found it works best if the output file is in .tif format)
Proximity (Raster Distance) calculator dialog

Proximity (Raster Distance) calculator dialog

  • I want to measure the distance to SSSI pixels with a value of 1 (that is what I set to be the value used for areas with SSSI designation)
  • Distance units are Geo (geographical) rather than pixels

The output is initially a grey square. I have made the following adjustments:-

  • Colour map – Puseudo colour
  • Global Transparency – 50%

It is worth exploring the options to invert the colour map and Contrast Enhancement

The SSSI sites are visible as the green polygons, the thematic is red for areas closest to sites and blue for areas furthest away:-

QGIS Distance Calculator Results1

Repeat the process for all the necessary layers:

Proximity Distance Calculator Results

Proximity Distance Calculator Results

Raster Calculator

The raster calculator is a powerful tool that performs mathematical operations on each cell in a raster. Examples of this can be to calculate elevation, distance or density.

In this case, I am going to use it to identify the areas that are greater than 1km from a SSSI site by applying queries to identify matching pixel values.

  1. Open the raster calculator
  2. Enter the following expression SSSI_Distance@1 > 1000

The map units are in metres, so 1,000m = 1km

The resulting raster appears as a grey box. As usual, adjust its display properties (e.g. Contrast Enhancement, Invert Map and Transparency). The areas that are further than 1km from a SSSI site are now highlighted in grey, with the sites visible in green:-

QGIS Distance Calculator5


Combining Raster Calculator with elevations

I want to identify which areas of Chetney Marshes would be flooded by a 2m rise in sea level.  I used LIDAR data in contour format as the elevation data:-

Chetney Marshes map

Chetney Marshes map

Create TIN

I am using the TIN method to create an elevation model as the area is relatively small and the data is supplied as contours. TIN’s are more accurate, especially if the source data isn’t in grid format. However they are slower to process, especially over very large areas.

Select Plugins, Interpolation to open the Interpolation dialogue:-

Raster Calc2

I made the following changes to the display properties:-

  • Colour map – Pusedocolour
  • Transparency – I set global transparency to 50%
Chetney Marsh after colour adjustment

Chetney Marsh after colour adjustment

Raster Calculator

I now have an elevation model of the area. I now use the Raster Calculator to identify each pixel with an elevation of less than 2m. The elevation is stored in the pixel value. The raster calculator will identify each pixel with band value of less than 2.

The expression is elevation < 2

Select Raster, Raster Calculator to open the Raster Calculator:-

Raster Calc4

To change the Display Properties for a layer, Right click on the Layer in the layers panel (Table of Contents) and select Properties. I made the following changes to the display properties so the areas that are less than 2m, and susceptible to flooding appear highlighted in blue:-

  • Style tab: Color map – Colormap
  • Transparency: Global transparency 50%
  • Colormap tab: I added 2 entries:-
    • 0.00 white
    • 1.00 blue
Chetney Marsh showing raster calculation results

Chetney Marsh showing raster calculation results

 


  • Page 1 of 1 ( 2 posts )
  • raster calculator

Back to Top

Sustaining Members